<?php include "antet.php"; include "func.php";

if (isset($_POST["x"], $_POST["y"])) {$x=clean($_POST["x"]); $y=clean($_POST["y"]);}
else {$x=rand(0, $m); $y=rand(0, $n);}

$mapsize = 3; // also will be refered in func.php map()
$data=map($x, $y);
$i=0;
function maptop($x, $y)
{
	global $lang;

	$output = "";
	$output .= "<div   align='left'>";
	$output .= "<label>".$lang['jumpTo']."</label>";
	$output .= "<input class='textbox' type='text' id='x' size='2' value='".$x."'/> ";
	$output .= "<input class='textbox' type='text' id='y' size='2' value='".$y."'/> ";
	$output .= "<input class='button' type='button'onClick='map()' value='".$lang['go']."'/>";
	$output .= "</br><label id='xmenu'>-</label>";

	return $output;
}
function mapcoork($mapsize,$x, $y)
{
	global $lang;

	$output = "<div  style='position: relative; top: 30px; left: 0px;'>";
	// y map coor loop
	for ($k = $mapsize; $k >= -$mapsize; $k--)
	{
		$st_x = ($k + $mapsize) * 40;
		$st_y = ($mapsize - $k) * 20;
		$output .= "<div style='position:absolute;left:".$st_x."px;top:".$st_y."px;width:50px;'>y".$y+$k."</div>";
	}
/*	// x map coor loop
	for ($j = -$mapsize; $j <= $mapsize; $j++)
	{
		$st_x = ($j + $mapsize) * 40;
		$st_y = 160 + ($j + $mapsize) * 20;
		$output .= "<div style='position:absolute;left:".$st_x."px;top:".$st_y."px;width:50px;'>x".$x+$j."</div>";
	}*/
$output .= "</div>";
return $output;
}


echo maptop($x, $y);
echo mapcoor($mapsize, $x, $y);
function mapcoor($mapsize, $x, $y)
{

echo "<div style='position: relative; top: 30px; left: 0px;'>";
// y map coor loop
for ($k = $mapsize; $k >= -$mapsize; $k--)
{
	$st_x = ($k + $mapsize) * 40;
	$st_y = ($mapsize - $k) * 20;
	?>
<div style='position:absolute;left:<?php echo $st_x; ?>px;top:<?php echo $st_y; ?>px;width:50px;'>y<?php echo $y+$k; ?></div>
	<?php
}
// x map coor loop
for ($j = -$mapsize; $j <= $mapsize; $j++)
{
	$st_x = ($j + $mapsize) * 40;
	$st_y = 160 + ($j + $mapsize) * 20;
	?>

<div style='position:absolute;left:<?php echo $st_x; ?>px;top:<?php echo $st_y; ?>px;width:50px;'>x<?php echo $x+$j; ?></div>
	<?php
}
echo "</div>";
}
?>
<div style="position: relative; top: 0; left: 20;"><?php
for ($k = $mapsize; $k >= (-1*$mapsize); $k--)
{
	for ($j = (-1*$mapsize); $j <= $mapsize; $j++)
	{
		$st_x = ($k + $mapsize) * 40 + ($j + $mapsize) * 40;
		$st_y = ($mapsize - $k) * 20 + ($j + $mapsize) * 20;
		//echo map_img($data, $x+$j, $y+$k, $i, $imgs);
		?> <img style='position:absolute;left:<?php echo $st_x; ?>px;top:<?php echo $st_y; ?>px;width:80px;height:80px;' <?php map_img($data, $x+$j, $y+$k, $i, $imgs); ?>>
<?php
	}
}
?> <img src="<?php echo $imgs ?>map/map_back.gif" border="0" usemap="#Map" style='position: absolute; left: 0px; top: 41px; width: 560px; height: 280px;'>
<map name="Map" id="Map">
	<?php
$i = 0;
for ($k = $mapsize; $k >= (-1*$mapsize); $k--)
{
	for ($j = (-1*$mapsize); $j <= $mapsize; $j++)
	{
		$st_x = ($k + $mapsize) * 40 + ($j + $mapsize) * 40;
		$st_y = ($mapsize - $k) * 20 + ($j + $mapsize) * 20;
		$coords = ($st_x + 40) . ',' . $st_y . ',' . ($st_x + 80) . ',' . ($st_y + 20) . ',' . ($st_x + 40) . ',' . ($st_y + 40) . ',' . $st_x . ',' . ($st_y + 20);
		?>
	<area shape="poly" coords='<?php echo $coords; ?>'
	<?php map_lnk($data, $x+$j, $y+$k, $i); ?>>
	<?php
	}
}
?>

	<area shape="circle" coords='482,38,15'	href="javascript: template('maptown_.php', '<?php echo "x=".$x."&y=".($y+1); ?>')" title="<?php echo $lang['North']; ?>">
	<area shape="circle" coords='77,241,15'	href="javascript: template('maptown_.php', '<?php echo "x=".$x."&y=".($y-1); ?>')" title="<?php echo $lang['South']; ?>">
	<area shape="circle" coords='482,241,15' href="javascript: template('maptown_.php', '<?php echo "x=".($x+1)."&y=".$y; ?>')"	title="<?php echo $lang['East']; ?>">
	<area shape="circle" coords='77,38,15' href="javascript: template('maptown_.php', '<?php echo "x=".($x-1)."&y=".$y; ?>')" title="<?php echo $lang['West']; ?>">
</map></div>
<div id="descriptor" style="position: relative; top: -25; left: 370;">
<table class="q_table_desc" style="border-collapse: collapse"
	width="250" border="1">
	<tr>
		<td colspan="2" align="center"><?php echo $lang['description'] ?>

	</tr>
	<tr>
		<td width="117" align="center"><?php echo $lang['player'] ?>
		<td></td>

	</tr>
	<tr>
		<td width="117" align="center"><?php echo $lang['population'] ?>
		<td></td>

	</tr>
	<tr>
		<td width="117" align="center"><?php echo $lang['alliance'] ?>
		<td></td>

	</tr>
</table>
</div>